﻿
using Microsoft.AspNetCore.Mvc.Filters;

namespace LocalNas.Application.Handle;
public class LogExceptionHandler : IGlobalExceptionHandler, ISingleton
{
    public Task OnExceptionAsync(ExceptionContext context)
    {
        var hubContext = App.GetService<IHubContext<LogHub, ILogClient>>();
        _ = hubContext.Clients.All.ReceiveMessage(new SendMessageData
        {
            Time = DateTime.Now,
            Title = "错误",
            MessageType = MessageTypeEnum.通知,
            Message = context.Exception.Message
        }); 
        return Task.CompletedTask;
    }

}
